1
00:00:01,030 --> 00:00:04,840
All right welcome to the last lesson in video.

2
00:00:04,840 --> 00:00:09,210
So in this video we are going to be scripting with Bash.

3
00:00:09,220 --> 00:00:12,190
Now this may seem a little overwhelming at first.

4
00:00:12,190 --> 00:00:16,510
What we're going to be doing is building out a ping sweeper script.

5
00:00:16,510 --> 00:00:18,490
It's going to be pretty basic.

6
00:00:18,760 --> 00:00:26,080
And what I want you to do is maybe just watch this video once and then the second time through really

7
00:00:26,080 --> 00:00:28,900
try to follow along with it.

8
00:00:28,900 --> 00:00:33,870
Take notes etc. I think a first time watch through you know just to get the concepts.

9
00:00:33,880 --> 00:00:35,650
Understand what I'm doing.

10
00:00:35,650 --> 00:00:38,750
And then the second time really really get hands on with it.

11
00:00:38,860 --> 00:00:41,220
And I think that will be probably the best way to learn.

12
00:00:41,250 --> 00:00:45,370
But if you have a different learning style please do go ahead and try that as well.

13
00:00:45,370 --> 00:00:47,950
The only thing I can say is don't let this intimidate you.

14
00:00:48,250 --> 00:00:54,250
Hopefully by the time the video's over with you will have a pretty good understanding on a basic scripting

15
00:00:54,250 --> 00:01:00,980
and how scripting can really be beneficial and improve our timing improve automation etc..

16
00:01:01,090 --> 00:01:06,610
So let's go ahead and quickly talk about some of the things are we learning in this video faces some

17
00:01:06,610 --> 00:01:09,610
of the commands and items are going to learn.

18
00:01:09,610 --> 00:01:15,180
We're going to talk about grep which is going to allow us to narrow down some results.

19
00:01:15,190 --> 00:01:21,580
We're also going to talk about cut and T are both of those are also going to help us narrow down some

20
00:01:21,580 --> 00:01:22,560
results.

21
00:01:22,570 --> 00:01:27,610
So basically we're going to start with a ping that we're going to send out and we're going to want to

22
00:01:27,790 --> 00:01:31,750
gather information back that says that ping was valid.

23
00:01:31,810 --> 00:01:34,810
So we want to know any computer that responded to us.

24
00:01:34,810 --> 00:01:35,980
Well how are we going to do that.

25
00:01:35,980 --> 00:01:40,560
Well we need to identify what a valid ping looks like.

26
00:01:40,570 --> 00:01:45,790
We're going to use grep to to kind of narrow down a string or a sentence or something that identifies

27
00:01:45,790 --> 00:01:52,420
with a positive ping and then we're going to cut out everything we don't want and use TR as well to

28
00:01:52,450 --> 00:01:54,100
cut some things out that we don't want.

29
00:01:55,060 --> 00:01:59,340
So we're going to put this into a script when it's all said and done.

30
00:01:59,440 --> 00:02:05,530
And we're also going to be talking about the usage of for loops and their importance not only with using

31
00:02:05,530 --> 00:02:12,390
them in this script but how we can use simple one liners to do everyday things for us.

32
00:02:12,400 --> 00:02:17,950
So I'll show you at the end of the video how we're going to use that and map and use a for loop with

33
00:02:17,950 --> 00:02:21,100
n map to run through and map script.

34
00:02:21,100 --> 00:02:29,300
So stay tuned through the video again if you are a hands on learner maybe first time through you.

35
00:02:29,300 --> 00:02:35,290
You try hands on but my recommendation here is to just sit back watch the video understand what's going

36
00:02:35,290 --> 00:02:35,920
on.

37
00:02:35,950 --> 00:02:37,900
Second time really follow along with it.

38
00:02:37,900 --> 00:02:40,710
Take notes and get the most that you can.

39
00:02:40,780 --> 00:02:41,910
This lesson.

40
00:02:41,910 --> 00:02:43,750
So let's go ahead and get started.

41
00:02:44,620 --> 00:02:45,060
All right.

42
00:02:45,060 --> 00:02:50,120
So now we're going to be covering bash scripting so the first thing we're going to do to cover before

43
00:02:50,120 --> 00:02:54,380
we get into writing our scripts is how to narrow down results.

44
00:02:54,530 --> 00:02:56,500
And we say narrowing down results.

45
00:02:56,600 --> 00:03:02,300
What we're saying is forgiving a block of text and we want to extract some information from that block

46
00:03:02,300 --> 00:03:03,180
of text.

47
00:03:03,230 --> 00:03:04,700
How are we going to do that.

48
00:03:04,700 --> 00:03:06,290
So that's all we're going to cover in this lesson.

49
00:03:07,810 --> 00:03:08,100
OK.

50
00:03:08,110 --> 00:03:10,460
So let's go ahead and get started.

51
00:03:10,550 --> 00:03:14,250
Well we're going to be doing today is narrowing down a ping result.

52
00:03:14,390 --> 00:03:20,000
So if we come into here and we need to paying an IP address within our system.

53
00:03:20,000 --> 00:03:30,690
So I'm going to be pinging 1 9 2 1 6 8 dot 1 dot 90 and you're going to see that it returns a sixty

54
00:03:30,720 --> 00:03:32,450
four bytes from that address.

55
00:03:32,480 --> 00:03:34,990
So it looks like we're getting a response.

56
00:03:34,990 --> 00:03:37,340
I'm going to hit control see here.

57
00:03:37,340 --> 00:03:44,390
So if you remember from the networking section we actually get a response unlimited until we cancel

58
00:03:44,390 --> 00:03:44,730
it right.

59
00:03:44,730 --> 00:03:47,090
Like we just controlled see here from ping.

60
00:03:47,090 --> 00:03:52,460
So there's another thing that we can do if we only want to send one packet and see if it's alive or

61
00:03:52,460 --> 00:03:54,620
not we can do a dash C of one.

62
00:03:54,630 --> 00:04:00,170
So we're just gonna do that so that's account of one we're sending one packet over if we set 10.

63
00:04:00,170 --> 00:04:03,340
It would send 10 packets over if that makes sense.

64
00:04:03,350 --> 00:04:06,950
So now we're going to do is we're gonna put this into a text file.

65
00:04:07,310 --> 00:04:12,350
So if you remember from previous video we just use this little carrot here and I'm going to call this

66
00:04:12,440 --> 00:04:15,630
IP that text OK.

67
00:04:15,630 --> 00:04:20,330
And if we can IP that text you'll see the same results there.

68
00:04:21,500 --> 00:04:24,750
So now what we're gonna want to do is we're gonna want to narrow this down.

69
00:04:24,860 --> 00:04:26,630
What do I want to extract from here.

70
00:04:26,630 --> 00:04:32,730
Well I want to extract this IP address and it'll make more sense when we get into the scripting part.

71
00:04:32,750 --> 00:04:39,060
But what we're gonna do is we're gonna get out specifically of this this IP address from this line.

72
00:04:39,170 --> 00:04:47,210
Now we're interested in actually is a returned IP address that has a valid response.

73
00:04:47,210 --> 00:04:47,510
Right.

74
00:04:47,540 --> 00:04:57,290
So if I were to attack or if I were to enter in here say 15 dot 90 OK there's no response there.

75
00:04:57,290 --> 00:05:00,950
So this is kind of what it looks like when it doesn't get a response back.

76
00:05:00,950 --> 00:05:02,840
It just kind of lingers.

77
00:05:02,840 --> 00:05:06,770
And then we hit control C and it says zero pinging statistics right.

78
00:05:06,770 --> 00:05:09,830
Nothing was was received back.

79
00:05:09,850 --> 00:05:17,010
So what we see when we get a response back is we see sixty four bytes when there's no response back.

80
00:05:17,020 --> 00:05:18,730
We don't have any bytes.

81
00:05:18,730 --> 00:05:23,080
So if we're doing a sweep through a network which we're going to be doing later we need to be able to

82
00:05:23,080 --> 00:05:24,900
narrow down these results.

83
00:05:24,940 --> 00:05:33,400
So if we're sending say 1 9 to that 1 6 8 that one that one all the way through 255 and we want to see

84
00:05:33,460 --> 00:05:38,700
who responds back and then take that list and narrow it down to the IP addresses which is exactly we're

85
00:05:38,710 --> 00:05:43,980
going to be doing we need to know how to narrow that down.

86
00:05:44,070 --> 00:05:47,760
So what we're gonna be narrowing down on specifically is the sixty 64 bytes.

87
00:05:48,450 --> 00:05:54,840
So lets tab up a couple times to this cat IP address and we're gonna do a pipe in the pipe just means

88
00:05:54,840 --> 00:05:57,150
we're gonna add an additional command here.

89
00:05:57,270 --> 00:06:02,280
So the additional command we're going to do is called grep grep is going to grab any line with what

90
00:06:02,280 --> 00:06:03,230
you specify.

91
00:06:03,660 --> 00:06:10,820
So let's specify sixty four bytes and see what happens see now if you noticed we had all of these lines

92
00:06:10,850 --> 00:06:18,540
before and now a group is doing is grep is taking only the lines that contain sixty four bytes.

93
00:06:18,590 --> 00:06:20,880
So again a valid response.

94
00:06:21,020 --> 00:06:27,070
So we have sixty four bytes here and we have achieved a response.

95
00:06:27,110 --> 00:06:31,910
So what we're going to do now is we're going to narrow this down some more.

96
00:06:32,030 --> 00:06:33,490
OK we've got this line here.

97
00:06:33,500 --> 00:06:36,600
But again we're still trying to extract this IP address.

98
00:06:36,950 --> 00:06:38,920
So how can we do that.

99
00:06:38,930 --> 00:06:41,030
Well there is a tool called cut.

100
00:06:41,030 --> 00:06:47,200
So if we tap up again and we do another pipe because they're sending a new command we're going to say

101
00:06:47,200 --> 00:06:49,040
cut and cut syntax.

102
00:06:49,040 --> 00:06:52,420
It looks like this and I'll explain it once I type it out here.

103
00:06:53,710 --> 00:06:58,600
OK so we have cut and then this hyphen D.

104
00:06:58,630 --> 00:06:59,950
That's a delimiter.

105
00:06:59,950 --> 00:07:03,040
So the delimiter is what we're going to be cutting on.

106
00:07:03,070 --> 00:07:10,680
So we're giving a delimiter of a space meaning here's a space here's the space here's a space.

107
00:07:10,690 --> 00:07:15,190
So we're gonna be cutting on these spaces and then we give a field.

108
00:07:15,190 --> 00:07:18,250
We say OK what field do we want to retrieve back from this cut.

109
00:07:18,880 --> 00:07:19,130
OK.

110
00:07:19,150 --> 00:07:20,650
We want to field for.

111
00:07:20,680 --> 00:07:27,710
If you look one two three four in the fourth field is our IP address.

112
00:07:27,790 --> 00:07:32,380
So it's gonna say OK I'm going to cut on this space I'm gonna cut in this space I'm going to cut on

113
00:07:32,380 --> 00:07:35,550
this space and then I can take it right here.

114
00:07:35,590 --> 00:07:40,990
Now if we identified field five we would be taking this fully identified field three we were taking

115
00:07:40,990 --> 00:07:47,050
from let's go ahead and just hit enter and see what that looks like OK.

116
00:07:47,050 --> 00:07:49,350
So now we are narrow down even more.

117
00:07:50,230 --> 00:07:51,890
But there's an issue here.

118
00:07:51,940 --> 00:07:58,210
If we were to try to send this IP address we would have this little colon here attached onto it and

119
00:07:58,240 --> 00:07:59,830
you can't ping with that IP address.

120
00:07:59,830 --> 00:08:04,540
So we're gonna be doing a sweep or narrowing down this list then we're gonna actually need to remove

121
00:08:04,570 --> 00:08:05,660
this guy here.

122
00:08:06,210 --> 00:08:08,400
So let's take a look at how we do that.

123
00:08:08,440 --> 00:08:12,380
So if we tap up again and again we're going to add a pipe.

124
00:08:12,630 --> 00:08:19,140
Now we're gonna use a command called TR and TR just means translate what we're gonna be doing is another

125
00:08:19,140 --> 00:08:20,030
delimiter.

126
00:08:20,220 --> 00:08:23,970
So dash D there and we're going to be taking out that call.

127
00:08:24,150 --> 00:08:25,580
So it should look something like this.

128
00:08:25,620 --> 00:08:29,260
If we hit Enter now you can see that that Colon has been removed.

129
00:08:29,810 --> 00:08:34,570
OK now let's talk about how we can use this information to write out a script.

130
00:08:34,770 --> 00:08:38,550
We're going to start with a basic script and we can add upon it as we go.

131
00:08:38,610 --> 00:08:43,320
So I've gone ahead and written out a script but we're going to talk about it very slowly so you can

132
00:08:43,320 --> 00:08:45,690
actually look at it and copy it down.

133
00:08:45,720 --> 00:08:53,000
So what we're going to do is go ahead and say get it and I called this IP sweep that S H.

134
00:08:53,010 --> 00:09:01,600
So go ahead and do the same or something similar to enter so let's take a look at this script so at

135
00:09:01,600 --> 00:09:04,290
the very top here we have to declare what we're doing.

136
00:09:04,450 --> 00:09:08,200
So we're going to give a hash bang and we do this with any scripting language.

137
00:09:08,290 --> 00:09:11,790
So if was or Python we'd be entering Python here but this is bash.

138
00:09:11,830 --> 00:09:16,870
So we're gonna be doing a forward slash bean forward slash bash that declares that we're running a bash

139
00:09:16,870 --> 00:09:24,060
script and the DSH also indicates that we're running a bash script so I want you to ignore this line

140
00:09:24,060 --> 00:09:25,740
here in this line here for now.

141
00:09:25,740 --> 00:09:26,940
Let's talk about this line.

142
00:09:26,940 --> 00:09:29,160
This should look very very familiar.

143
00:09:29,250 --> 00:09:35,190
So we're doing in this line we are saying we're going to ping with a count of one which we talked about

144
00:09:36,090 --> 00:09:37,880
and then we're going to do something here.

145
00:09:38,010 --> 00:09:40,160
We've got a dollar sign one and a dollar sign.

146
00:09:40,160 --> 00:09:45,760
IP let's just ignore that for now OK so we're gonna go ahead and do the rest.

147
00:09:45,760 --> 00:09:46,840
That should look familiar.

148
00:09:46,840 --> 00:09:49,600
We're gonna say run a grab sixty bytes.

149
00:09:49,660 --> 00:09:55,810
We're gonna cut the delimiter of a space feel the floor and then we're going to do a translate right

150
00:09:55,840 --> 00:09:57,750
and take off that little bit at the end.

151
00:09:58,500 --> 00:10:01,200
OK I added Ampersand here at the end.

152
00:10:01,300 --> 00:10:03,610
So an ad first hand allows us to do threading.

153
00:10:03,700 --> 00:10:05,710
So that's exactly why it's in there.

154
00:10:05,740 --> 00:10:07,860
If we didn't we'd have to let the process go.

155
00:10:07,870 --> 00:10:10,830
One IP at a time and we'll talk about that in a second as well.

156
00:10:12,430 --> 00:10:19,150
So let's talk about this for line so a for loop is what we're actually running here and the loop is

157
00:10:19,150 --> 00:10:22,240
saying I want to do an IP address.

158
00:10:22,240 --> 00:10:25,080
We're just declaring a variable here you can call it whatever you want.

159
00:10:25,240 --> 00:10:32,230
Or we're saying hey for this IP in a sequence of 1 through 254 we're gonna do something in that do as

160
00:10:32,230 --> 00:10:33,190
a pain.

161
00:10:33,190 --> 00:10:38,920
So what this means is for IP and if we think about it in sequence 1 through 250 for what it's saying

162
00:10:38,920 --> 00:10:42,990
is 1 2 3 4 all the way up to 254.

163
00:10:43,080 --> 00:10:43,450
OK.

164
00:10:43,480 --> 00:10:51,240
So think about it this way if we say 4 1 in this ping sweep we're gonna do that right.

165
00:10:51,270 --> 00:10:57,110
So we're gonna say 4 1 4 2 4 3 all the way through 254.

166
00:10:57,120 --> 00:10:59,040
That's what this loop is doing.

167
00:10:59,040 --> 00:11:01,260
So it's very very simple loop.

168
00:11:01,260 --> 00:11:06,210
Now IP is replaced down here at the very end.

169
00:11:06,210 --> 00:11:09,240
Now we're also calling out this dollar sign 1.

170
00:11:09,250 --> 00:11:12,210
Now this dollar sign 1 is user input.

171
00:11:12,510 --> 00:11:14,640
So we're going to actually do something.

172
00:11:14,640 --> 00:11:17,040
This is called IP sweep right.

173
00:11:17,040 --> 00:11:23,780
So we're gonna have to call out this IP sweep something like this sage and then we're going to have

174
00:11:23,780 --> 00:11:25,820
to give out some information.

175
00:11:25,820 --> 00:11:28,310
It's going to request information if we don't provide it.

176
00:11:28,340 --> 00:11:29,720
It won't know how to ping.

177
00:11:29,960 --> 00:11:35,360
So we're gonna do is we're gonna say the first three octet of our home network.

178
00:11:35,360 --> 00:11:38,090
So of yours is 1 9 2 1 6 8.

179
00:11:38,090 --> 00:11:44,510
That one like mine is then you just enter 1 9 2 1 6 8 1.

180
00:11:44,510 --> 00:11:54,020
Now we could also for simplicity just hard code this so we can say 1 9 2 1 6 8 dot 1 dot IP address

181
00:11:54,650 --> 00:11:56,690
and it would be fine.

182
00:11:56,690 --> 00:11:57,990
We don't have to build the set.

183
00:11:58,010 --> 00:12:03,950
The only reason we're not hard coding it is because you can do multiple pings slaves is going to be

184
00:12:03,950 --> 00:12:08,300
a ping sleep script for you in the future if you're on a different network or you just want to write

185
00:12:08,300 --> 00:12:10,560
something out really quick dollar sign one.

186
00:12:10,560 --> 00:12:12,350
Works perfect.

187
00:12:12,350 --> 00:12:15,470
But if you want to leave it hard coded like this it will also work.

188
00:12:15,920 --> 00:12:18,690
So let's go ahead and just delete this out.

189
00:12:19,040 --> 00:12:27,190
I'm going to put this into dollar sign 1 again to have a proof of concept and then we are going to run

190
00:12:27,190 --> 00:12:27,990
this.

191
00:12:28,060 --> 00:12:34,590
So all we do here at the end is declare done if we didn't run this with an ampersand here we would have

192
00:12:34,590 --> 00:12:41,010
to add a semicolon similar to this but because we are having an ampersand we can actually get rid of

193
00:12:41,010 --> 00:12:46,410
that and just put that back just for some syntax clarity here.

194
00:12:46,410 --> 00:12:48,090
OK so let's go ahead and save this

195
00:12:50,820 --> 00:12:56,190
and remember from our lesson we're gonna have to change the mode of our script because it's not executable

196
00:12:56,190 --> 00:12:57,090
by default.

197
00:12:57,510 --> 00:13:03,360
So we're gonna do a plus X here and then we're gonna call our IP sweep the h we can l s and make sure

198
00:13:03,360 --> 00:13:04,480
it's green.

199
00:13:04,620 --> 00:13:06,740
Here's IPC if the S H.

200
00:13:07,110 --> 00:13:10,170
And then we'll do a dot for it slash IP sweep to S H.

201
00:13:10,200 --> 00:13:15,270
And I'm not going to enter anything in as one to show proof of concept so see it ran through every single

202
00:13:15,270 --> 00:13:21,540
number here and threading and name or service not knowing because we didn't provide an IP address.

203
00:13:21,540 --> 00:13:29,730
So what we can do here is we need to provide that IP address 1 6 8 that one hit Enter okay and it pulls

204
00:13:29,730 --> 00:13:33,900
back some information so what we can do with this information.

205
00:13:33,900 --> 00:13:39,620
Let's write this out to a file so let's just call this IP list.

206
00:13:39,630 --> 00:13:40,790
That text.

207
00:13:40,800 --> 00:13:42,990
Something like this OK.

208
00:13:42,990 --> 00:13:43,860
It's done.

209
00:13:43,980 --> 00:13:45,710
Now let's just cut out the IP list.

210
00:13:45,720 --> 00:13:48,340
Text OK.

211
00:13:48,360 --> 00:13:55,220
Now we have an IP list of the IP is in our network that we just swept right and we can use this information

212
00:13:55,220 --> 00:13:56,110
later on.

213
00:13:56,180 --> 00:14:01,580
But before we go into that I do want to go back and just improve our script a very very tiny bit.

214
00:14:01,610 --> 00:14:07,650
So let's go ahead and just tab up a couple of times so we get to our edit and let me show you how we

215
00:14:07,650 --> 00:14:09,160
can improve this script.

216
00:14:09,360 --> 00:14:11,730
It doesn't have to be overly complicated.

217
00:14:11,820 --> 00:14:19,810
What we can do is we can say something like this we can come in here and give an if statement.

218
00:14:19,830 --> 00:14:20,760
So if his condition.

219
00:14:20,760 --> 00:14:24,350
All right we're gonna say if this exists then do something.

220
00:14:24,360 --> 00:14:27,090
And if it doesn't exist do something else.

221
00:14:27,090 --> 00:14:37,680
So we're gonna say if dollar sign 1 is equal to nothing we're going to give it blank space here and

222
00:14:38,310 --> 00:14:41,950
then we're gonna say then we want to do something.

223
00:14:42,000 --> 00:14:43,630
So what are we going to do.

224
00:14:43,770 --> 00:14:55,130
We can echo out something similar to you forgot an IP address and then echo out what you need to do

225
00:14:56,150 --> 00:14:57,710
like syntax

226
00:15:00,430 --> 00:15:05,520
that slash ping suite or IP suite is what we call this IP suite.

227
00:15:05,520 --> 00:15:12,740
That s h and then IP or we can even write it out.

228
00:15:12,760 --> 00:15:14,040
An example right.

229
00:15:15,380 --> 00:15:16,480
Something like that.

230
00:15:16,550 --> 00:15:19,670
So that way our user if they're using it we wrote this for somebody else.

231
00:15:19,670 --> 00:15:22,550
They know we're talking about it at the very end.

232
00:15:22,550 --> 00:15:24,310
We just need to write if backwards.

233
00:15:24,320 --> 00:15:25,900
We'll put it FDI.

234
00:15:25,970 --> 00:15:33,320
So what this is saying is if this is not an echo here right we're going to echo these and then we need

235
00:15:33,320 --> 00:15:35,090
to add one other thing here which is it.

236
00:15:35,100 --> 00:15:38,790
Else go ahead and hit enter just the spaces out of it.

237
00:15:38,810 --> 00:15:43,660
So if we have no dollar sign one declared.

238
00:15:43,660 --> 00:15:43,840
Right.

239
00:15:43,850 --> 00:15:49,880
If we have nothing entered in we're gonna say echo you forgot an IP address and syntax here.

240
00:15:49,880 --> 00:15:51,800
If we do have something in dollar sign one.

241
00:15:52,240 --> 00:15:52,630
OK.

242
00:15:52,640 --> 00:15:58,370
We're gonna do something else we're gonna do our pink suite and that's it.

243
00:15:58,440 --> 00:16:04,290
So this is very similar and modified from Georgia wide means that I've got a long time ago so full credit

244
00:16:04,290 --> 00:16:06,750
goes to her for this little script.

245
00:16:06,940 --> 00:16:11,650
It was very very easy to learn and it's also very easy to teach.

246
00:16:11,670 --> 00:16:18,690
So let's go ahead and just run this one more time we're gonna say IP sweep the s h and look what happens

247
00:16:18,720 --> 00:16:21,310
now it says you forgot an IP address.

248
00:16:21,390 --> 00:16:24,990
Now we can declare a number and there anything in the script is not perfect right.

249
00:16:25,110 --> 00:16:32,040
We're expecting three octet and we could give it a 1 and it's still going to do something like that

250
00:16:32,070 --> 00:16:33,080
which is incorrect right.

251
00:16:33,870 --> 00:16:40,790
So we need to be able to to modify this down more but that gets really advanced scripting into declaring

252
00:16:40,790 --> 00:16:44,950
that needs to be three act tatts and if you don't provide those then what.

253
00:16:44,990 --> 00:16:49,310
And that just gets more advanced so we really just need to know hey what we're doing here.

254
00:16:49,340 --> 00:16:53,780
Very basic script for ourselves and something to remember.

255
00:16:53,940 --> 00:16:54,360
OK.

256
00:16:54,400 --> 00:16:55,660
Let's clear our screen.

257
00:16:55,660 --> 00:16:57,550
Last thing I want to show you.

258
00:16:57,610 --> 00:17:03,820
So we've been able to write a script out but we can also do looping in one line.

259
00:17:03,820 --> 00:17:06,290
And this is where it becomes kind of fun.

260
00:17:06,340 --> 00:17:08,440
So we have this IP list right.

261
00:17:08,440 --> 00:17:11,670
We did a cat IP list that Tex.

262
00:17:11,910 --> 00:17:18,380
Now let's say we've got this IP list together and we want to do an end map scan on all of these IP.

263
00:17:18,720 --> 00:17:26,940
Now we could just say and map and type in the syntax you want and the IP address of it for every single

264
00:17:26,940 --> 00:17:28,440
one of these starting new tab.

265
00:17:28,520 --> 00:17:34,920
And let that happen or you could do something in a for loop so we can write the same for loop that we

266
00:17:34,920 --> 00:17:36,390
did before.

267
00:17:36,400 --> 00:17:41,750
We're gonna say for IP and then we're we're gonna do is we're gonna write a dollar sign and we're gonna

268
00:17:41,760 --> 00:17:46,230
cat the IP list that text.

269
00:17:46,230 --> 00:17:51,480
So all it does is is bringing out this list that we have here and it's saying OK for this IP this IP

270
00:17:51,480 --> 00:17:53,370
this IP set we're going to run through all of these.

271
00:17:53,370 --> 00:17:54,240
That's what the loop does.

272
00:17:54,240 --> 00:17:55,300
Right.

273
00:17:55,370 --> 00:17:55,810
OK.

274
00:17:55,950 --> 00:18:00,300
We're gonna do our semicolon then we're going to tell it to do something right.

275
00:18:00,330 --> 00:18:01,380
So what do we want to do.

276
00:18:02,070 --> 00:18:03,880
OK let's run it and map script.

277
00:18:04,020 --> 00:18:13,130
So we're gonna say do and map and we'll ping or we'll do a port Port 80 on all of these and we'll say

278
00:18:13,140 --> 00:18:21,240
stealth scan that port 80 and we'll do T4 for a speed and that should be it.

279
00:18:21,260 --> 00:18:24,180
So then we can do.

280
00:18:24,450 --> 00:18:27,620
Done like this and let it run through one at a time.

281
00:18:27,720 --> 00:18:32,280
We can also do the ampersand and let it run multiples like this.

282
00:18:32,340 --> 00:18:34,710
We can hit enter and see what that does.

283
00:18:34,740 --> 00:18:39,180
But I also forgot one thing here forgot to declare the IP address.

284
00:18:39,180 --> 00:18:42,050
So let's talk about it real quick.

285
00:18:42,120 --> 00:18:45,730
So we've got a very very simple one liner and you're going to see one liners a lot.

286
00:18:45,750 --> 00:18:50,900
If you get into ethical hacking and just allows us to do things quickly and scripted.

287
00:18:51,150 --> 00:18:53,850
So we got four IP address in this list.

288
00:18:53,850 --> 00:18:57,560
So every IP in this list we're gonna loop through when we do that loop.

289
00:18:57,570 --> 00:19:05,490
We're gonna do and map we do a quick stealth scan of port 80 T4 and we're gonna say declare the IP address

290
00:19:05,820 --> 00:19:07,130
if you're not comfortable and map.

291
00:19:07,140 --> 00:19:07,680
That's OK.

292
00:19:07,680 --> 00:19:11,500
This is purely an example and something you will see in your career.

293
00:19:11,520 --> 00:19:16,210
I will make a scripting video at some point for and map and we'll cover and map more in detail.

294
00:19:16,350 --> 00:19:17,880
So let's go ahead and just hit enter.

295
00:19:18,180 --> 00:19:18,540
OK.

296
00:19:18,570 --> 00:19:20,210
I messed up my syntax.

297
00:19:20,670 --> 00:19:23,010
So what's going on.

298
00:19:23,040 --> 00:19:23,840
OK.

299
00:19:24,150 --> 00:19:35,680
So for IP in this cut deleted for IP and cat IP let's try this one more time so we just did all these

300
00:19:35,680 --> 00:19:41,350
scans seven scans at once and what we did is you see these are the processes that are starting.

301
00:19:41,350 --> 00:19:46,840
So it started up eight processes actually not seven and it's just running through this list doing the

302
00:19:46,840 --> 00:19:50,800
scans and we're gonna go ahead and just kind of look at it.

303
00:19:50,830 --> 00:19:56,170
So it says Okay on one dot Seventy four is eighty open it's open.

304
00:19:56,170 --> 00:19:57,010
Okay.

305
00:19:57,070 --> 00:20:02,530
And then on two fifty four is eighty open it's open and then you see filter down here where it's not

306
00:20:02,530 --> 00:20:05,060
running filtered filtered same thing.

307
00:20:05,170 --> 00:20:09,010
So we can hit control C or hit enter for done.

308
00:20:09,010 --> 00:20:10,360
And that's pretty much it.

309
00:20:10,390 --> 00:20:16,180
So what we just did is we ran AMF scans at one time instead of having to copy and paste these.

310
00:20:16,240 --> 00:20:19,380
So it's just a little bit of what scripting can do.

311
00:20:19,630 --> 00:20:25,660
It does get more advanced but be able to know a one line for loop is a really really important.

312
00:20:25,660 --> 00:20:32,360
If you go into penetration testing and it's just important in basic bash scripting as well.

313
00:20:32,650 --> 00:20:34,250
So that's it for this lesson.

314
00:20:34,360 --> 00:20:38,260
I will catch you guys over in the next lesson when we start on introductory Python.
